package uplb.ics.cs190.e2d.time;

public class FPSCounter {

	protected long lastCount;
	
	protected int currentFPS;
	protected int frameCount;
	
	public FPSCounter() {
		
	}
	
	public void refresh() {
		this.frameCount = 0;
		this.lastCount = System.currentTimeMillis();
	}
	
	public void calculateFPS() {
		this.frameCount++;
		if(System.currentTimeMillis() - this.lastCount > 1000) {
			this.lastCount = System.currentTimeMillis();
			this.currentFPS = this.frameCount;
			this.frameCount = 0;
		}
	}
	
	public int getFPS() {
		return this.currentFPS;
	}
}
